/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yray.websocket.nettyws.ui;

import io.netty.handler.codec.http.DefaultHttpHeaders;
import io.netty.handler.codec.http.HttpHeaders;

import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.yray.websocket.nettyws.constants.AutoSendStatusEnum;
import org.yray.websocket.nettyws.constants.ConnectStatusEnum;
import org.yray.websocket.nettyws.data.AutoIntervalListModel;
import org.yray.websocket.nettyws.data.AutoListModel;
import org.yray.websocket.nettyws.data.ConnectModel;
import org.yray.websocket.nettyws.data.ManualListModel;
import org.yray.websocket.nettyws.document.NumberDocument;
import org.yray.websocket.nettyws.netty.WebSocketClient;
import org.yray.websocket.nettyws.netty.handler.auto.AutoSendMessageHandler;
import org.yray.websocket.nettyws.netty.handler.request.RequestReplacesContent;
import org.yray.websocket.nettyws.utils.JsonUtil;

import javax.swing.*;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.stream.IntStream;

/**
 *
 * @author DELL
 */
public class SwingApp extends JFrame {
    private WebSocketClient webSocketClient = new WebSocketClient();
    private AutoSendMessageHandler autoSendMessageHandler = new AutoSendMessageHandler();
    private ManualListModel manualListModel = new ManualListModel();
    private AutoListModel autoListModel = new AutoListModel();
    private ConnectModel connectModel = new ConnectModel();
    private AutoIntervalListModel autoIntervalListModel = new AutoIntervalListModel();
    private RequestReplacesContent requestReplacesContent;

    @Autowired
    public void setRequestReplacesContent(RequestReplacesContent requestReplacesContent) {
        this.requestReplacesContent = requestReplacesContent;
    }
    @Autowired
    public void setWebSocketClient(WebSocketClient webSocketClient) {
        this.webSocketClient = webSocketClient;
    }
    @Autowired
    public void setAutoSendMessageHandler(AutoSendMessageHandler autoSendMessageHandler) {
        this.autoSendMessageHandler = autoSendMessageHandler;
    }

    public SwingApp(ManualListModel manualListModel, AutoListModel autoListModel, ConnectModel connectModel, AutoIntervalListModel autoIntervalListModel) {
        this.manualListModel = manualListModel;
        this.autoListModel = autoListModel;
        this.connectModel = connectModel;
        this.autoIntervalListModel = autoIntervalListModel;
        initComponents();
    }


    /**
     * Creates new form main
     */
    public SwingApp() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainMenuJTabbedPane = new JTabbedPane();
        connectJPanel = new JPanel();
        jPanel2 = new JPanel();
        jLabel1 = new JLabel();
        WSUrl = new JTextField();
        WSHeaders = new JPanel();
        jPanel4 = new JPanel();
        WSHeadersKey = new JTextField();
        WSHeadersValue = new JTextField();
        jPanel6 = new JPanel();
        WSHeadersKey1 = new JTextField();
        WSHeadersValue1 = new JTextField();
        jPanel8 = new JPanel();
        WSHeadersKey2 = new JTextField();
        WSHeadersValue2 = new JTextField();
        connectButton = new JButton();
        manualSendJPanel = new JPanel();
        jSplitPane4 = new JSplitPane();
        jPanel7 = new JPanel();
        jPanel5 = new JPanel();
        jSplitPane1 = new JSplitPane();
        jScrollPane1 = new JScrollPane();
        sendEventList = new JList<>();
        jScrollPane4 = new JScrollPane();
        sendEvnetMessageArea = new JTextArea();
        jPanel10 = new JPanel();
        addSendEventButton = new JButton();
        delSendEventButton = new JButton();
        sendEventButton = new JButton();
        addSendEventNameText = new JTextField();
        jScrollPane2 = new JScrollPane();
        manualTextArea = new JTextArea();
        autoSendJPanel = new JPanel();
        jSplitPane2 = new JSplitPane();
        jPanel9 = new JPanel();
        jPanel11 = new JPanel();
        jSplitPane3 = new JSplitPane();
        jScrollPane6 = new JScrollPane();
        autoSendEventList = new JList<>();
        jScrollPane7 = new JScrollPane();
        autoSendEvnetMessageArea = new JTextArea();
        jPanel12 = new JPanel();
        jPanel13 = new JPanel();
        autoIntervalText = new JTextField();
        autoIntervalButton = new JButton();
        jLabel2 = new JLabel();
        jPanel14 = new JPanel();
        autoSendEventNameText = new JTextField();
        addAutoSendEventButton = new JButton();
        delAutoSendEventButton = new JButton();
        jScrollPane5 = new JScrollPane();
        autoTextArea = new JTextArea();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        mainMenuJTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                mainMenuJTabbedPaneStateChanged(evt);
            }
        });

        connectJPanel.setBorder(BorderFactory.createTitledBorder(null, null, 0, 0, null, new java.awt.Color(102, 102, 102)));

        jLabel1.setText("url");

        WSUrl.setText(connectModel.getConnectionUrl());
        WSUrl.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WSUrlActionPerformed(evt);
            }
        });

        GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(WSUrl)
                .addGap(29, 29, 29))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(WSUrl, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        WSHeaders.setBorder(BorderFactory.createTitledBorder(""));
        WSHeaders.setLayout(new java.awt.BorderLayout());

        WSHeadersKey.setText(connectModel.getHeaders().keySet().stream().findFirst().orElse(""));
        WSHeadersKey.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WSHeadersKeyActionPerformed(evt);
            }
        });

        WSHeadersValue.setText(connectModel.getHeaders().get(connectModel.getHeaders().keySet().stream().findFirst().orElse("")));
        WSHeadersValue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WSHeadersValueActionPerformed(evt);
            }
        });

        GroupLayout jPanel4Layout = new GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(WSHeadersKey, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(WSHeadersValue, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(WSHeadersKey, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(WSHeadersValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        WSHeaders.add(jPanel4, java.awt.BorderLayout.CENTER);

        WSHeadersKey1.setText(connectModel.getHeaders().keySet().stream().findFirst().orElse(""));
        WSHeadersKey1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WSHeadersKey1ActionPerformed(evt);
            }
        });

        WSHeadersValue1.setText(connectModel.getHeaders().get(connectModel.getHeaders().keySet().stream().findFirst().orElse("")));
        WSHeadersValue1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WSHeadersValue1ActionPerformed(evt);
            }
        });

        GroupLayout jPanel6Layout = new GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(WSHeadersKey1, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(WSHeadersValue1, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(WSHeadersKey1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(WSHeadersValue1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        WSHeaders.add(jPanel6, java.awt.BorderLayout.PAGE_START);

        WSHeadersKey2.setText(connectModel.getHeaders().keySet().stream().findFirst().orElse(""));
        WSHeadersKey2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WSHeadersKey2ActionPerformed(evt);
            }
        });

        WSHeadersValue2.setText(connectModel.getHeaders().get(connectModel.getHeaders().keySet().stream().findFirst().orElse("")));
        WSHeadersValue2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WSHeadersValue2ActionPerformed(evt);
            }
        });

        GroupLayout jPanel8Layout = new GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(WSHeadersKey2, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(WSHeadersValue2, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(WSHeadersKey2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(WSHeadersValue2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        WSHeaders.add(jPanel8, java.awt.BorderLayout.PAGE_END);

        connectButton.setText("connect");
        connectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                connectButtonActionPerformed(evt);
            }
        });

        GroupLayout connectJPanelLayout = new GroupLayout(connectJPanel);
        connectJPanel.setLayout(connectJPanelLayout);
        connectJPanelLayout.setHorizontalGroup(
            connectJPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(WSHeaders, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(connectJPanelLayout.createSequentialGroup()
                .addGap(307, 307, 307)
                .addComponent(connectButton)
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        connectJPanelLayout.setVerticalGroup(
            connectJPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(connectJPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(WSHeaders, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(connectButton)
                .addContainerGap(282, Short.MAX_VALUE))
        );

        mainMenuJTabbedPane.addTab("ws-connect", connectJPanel);

        jSplitPane4.setDividerLocation(340);

        jPanel7.setLayout(new java.awt.BorderLayout());

        jSplitPane1.setDividerLocation(200);
        jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);

        sendEventList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
                sendEventListMouseClicked(evt);
            }
        });
        sendEventList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                sendEventListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(sendEventList);

        jSplitPane1.setTopComponent(jScrollPane1);

        sendEvnetMessageArea.setColumns(20);
        sendEvnetMessageArea.setRows(5);
        sendEvnetMessageArea.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
                sendEvnetMessageAreaCaretPositionChanged(evt);
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                sendEvnetMessageAreaInputMethodTextChanged(evt);
            }
        });
        jScrollPane4.setViewportView(sendEvnetMessageArea);
        //sendEvnetMessageArea.getDocument().addDocumentListener(new DocumentListener(){
            //
            //@Override
            //public void insertUpdate(DocumentEvent e) {
                //	System.out.println("insertUpdate");
                //}
            //
            //@Override
            //public void removeUpdate(DocumentEvent e) {
                //	System.out.println("removeUpdate");
                //}
            //
            //@Override
            //public void changedUpdate(DocumentEvent e) {
                //	System.out.println("changedUpdate");
                //}
            //});

    jSplitPane1.setRightComponent(jScrollPane4);

    GroupLayout jPanel5Layout = new GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(
        jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 339, Short.MAX_VALUE)
        .addGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE))
    );
    jPanel5Layout.setVerticalGroup(
        jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 505, Short.MAX_VALUE)
        .addGroup(jPanel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE))
    );

    jPanel7.add(jPanel5, java.awt.BorderLayout.CENTER);

    jPanel10.setPreferredSize(new java.awt.Dimension(339, 50));

    addSendEventButton.setText("add");
    addSendEventButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            addSendEventButtonActionPerformed(evt);
        }
    });

    delSendEventButton.setText("del");
    delSendEventButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            delSendEventButtonActionPerformed(evt);
        }
    });

    sendEventButton.setText("send");
    sendEventButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            sendEventButtonActionPerformed(evt);
        }
    });

    addSendEventNameText.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            addSendEventNameTextActionPerformed(evt);
        }
    });

    GroupLayout jPanel10Layout = new GroupLayout(jPanel10);
    jPanel10.setLayout(jPanel10Layout);
    jPanel10Layout.setHorizontalGroup(
        jPanel10Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel10Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(addSendEventNameText, GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
            .addGap(18, 18, 18)
            .addComponent(addSendEventButton)
            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(delSendEventButton)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(sendEventButton)
            .addGap(18, 18, 18))
    );
    jPanel10Layout.setVerticalGroup(
        jPanel10Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel10Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel10Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(delSendEventButton)
                .addComponent(sendEventButton)
                .addComponent(addSendEventNameText, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addComponent(addSendEventButton))
            .addContainerGap(17, Short.MAX_VALUE))
    );

    jPanel7.add(jPanel10, java.awt.BorderLayout.PAGE_END);

    jSplitPane4.setLeftComponent(jPanel7);

    manualTextArea.setEditable(false);
    manualTextArea.setBackground(new java.awt.Color(244, 244, 244));
    manualTextArea.setColumns(20);
    manualTextArea.setRows(5);
    manualTextArea.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            manualTextAreaMouseClicked(evt);
        }
    });
    jScrollPane2.setViewportView(manualTextArea);

    jSplitPane4.setRightComponent(jScrollPane2);

    GroupLayout manualSendJPanelLayout = new GroupLayout(manualSendJPanel);
    manualSendJPanel.setLayout(manualSendJPanelLayout);
    manualSendJPanelLayout.setHorizontalGroup(
        manualSendJPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addComponent(jSplitPane4, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 736, Short.MAX_VALUE)
    );
    manualSendJPanelLayout.setVerticalGroup(
        manualSendJPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addComponent(jSplitPane4, GroupLayout.Alignment.TRAILING)
    );

    mainMenuJTabbedPane.addTab("manual-send", manualSendJPanel);

    jSplitPane2.setDividerLocation(340);
    jSplitPane2.setMinimumSize(new java.awt.Dimension(250, 25));

    jPanel9.setLayout(new java.awt.BorderLayout());

    jSplitPane3.setDividerLocation(190);
    jSplitPane3.setOrientation(JSplitPane.VERTICAL_SPLIT);

    autoSendEventList.setModel(new AbstractListModel<String>() {
        String[] strings = { "" };
        public int getSize() { return strings.length; }
        public String getElementAt(int i) { return strings[i]; }
    });
    autoSendEventList.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            autoSendEventListMouseClicked(evt);
        }
    });
    jScrollPane6.setViewportView(autoSendEventList);

    jSplitPane3.setTopComponent(jScrollPane6);

    autoSendEvnetMessageArea.setColumns(20);
    autoSendEvnetMessageArea.setRows(5);
    jScrollPane7.setViewportView(autoSendEvnetMessageArea);

    jSplitPane3.setRightComponent(jScrollPane7);

    GroupLayout jPanel11Layout = new GroupLayout(jPanel11);
    jPanel11.setLayout(jPanel11Layout);
    jPanel11Layout.setHorizontalGroup(
        jPanel11Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 339, Short.MAX_VALUE)
        .addGroup(jPanel11Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane3, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE))
    );
    jPanel11Layout.setVerticalGroup(
        jPanel11Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 475, Short.MAX_VALUE)
        .addGroup(jPanel11Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane3, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE))
    );

    jPanel9.add(jPanel11, java.awt.BorderLayout.CENTER);

    jPanel12.setLayout(new java.awt.BorderLayout());

    jPanel13.setBorder(BorderFactory.createEtchedBorder());
    jPanel13.setPreferredSize(new java.awt.Dimension(249, 40));

    autoIntervalText.setDocument(new NumberDocument());
    autoIntervalText.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            autoIntervalTextActionPerformed(evt);
        }
    });

    autoIntervalButton.setText("openAutoSend");
    autoIntervalButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            autoIntervalButtonActionPerformed(evt);
        }
    });

    jLabel2.setText("interval:s");

    GroupLayout jPanel13Layout = new GroupLayout(jPanel13);
    jPanel13.setLayout(jPanel13Layout);
    jPanel13Layout.setHorizontalGroup(
        jPanel13Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel13Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(autoIntervalText, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jLabel2)
            .addGap(18, 18, 18)
            .addComponent(autoIntervalButton)
            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel13Layout.setVerticalGroup(
        jPanel13Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel13Layout.createSequentialGroup()
            .addGroup(jPanel13Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(autoIntervalText, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel2)
                .addComponent(autoIntervalButton))
            .addGap(0, 13, Short.MAX_VALUE))
    );

    jPanel12.add(jPanel13, java.awt.BorderLayout.CENTER);

    jPanel14.setBorder(BorderFactory.createEtchedBorder());
    jPanel14.setPreferredSize(new java.awt.Dimension(249, 40));

    autoSendEventNameText.setMinimumSize(new java.awt.Dimension(16, 21));
    autoSendEventNameText.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            autoSendEventNameTextActionPerformed(evt);
        }
    });

    addAutoSendEventButton.setText("add");
    addAutoSendEventButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            addAutoSendEventButtonActionPerformed(evt);
        }
    });

    delAutoSendEventButton.setText("del");
    delAutoSendEventButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            delAutoSendEventButtonActionPerformed(evt);
        }
    });

    GroupLayout jPanel14Layout = new GroupLayout(jPanel14);
    jPanel14.setLayout(jPanel14Layout);
    jPanel14Layout.setHorizontalGroup(
        jPanel14Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel14Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(autoSendEventNameText, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE)
            .addGap(18, 18, 18)
            .addComponent(addAutoSendEventButton)
            .addGap(18, 18, 18)
            .addComponent(delAutoSendEventButton)
            .addContainerGap(69, Short.MAX_VALUE))
    );
    jPanel14Layout.setVerticalGroup(
        jPanel14Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel14Layout.createSequentialGroup()
            .addGroup(jPanel14Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(autoSendEventNameText, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addComponent(addAutoSendEventButton)
                .addComponent(delAutoSendEventButton))
            .addGap(0, 13, Short.MAX_VALUE))
    );

    jPanel12.add(jPanel14, java.awt.BorderLayout.PAGE_START);

    jPanel9.add(jPanel12, java.awt.BorderLayout.PAGE_END);

    jSplitPane2.setLeftComponent(jPanel9);

    autoTextArea.setEditable(false);
    autoTextArea.setBackground(new java.awt.Color(243, 243, 243));
    autoTextArea.setColumns(20);
    autoTextArea.setRows(5);
    autoTextArea.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            autoTextAreaMouseClicked(evt);
        }
    });
    jScrollPane5.setViewportView(autoTextArea);

    jSplitPane2.setRightComponent(jScrollPane5);

    GroupLayout autoSendJPanelLayout = new GroupLayout(autoSendJPanel);
    autoSendJPanel.setLayout(autoSendJPanelLayout);
    autoSendJPanelLayout.setHorizontalGroup(
        autoSendJPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addComponent(jSplitPane2, GroupLayout.DEFAULT_SIZE, 736, Short.MAX_VALUE)
    );
    autoSendJPanelLayout.setVerticalGroup(
        autoSendJPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addComponent(jSplitPane2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    mainMenuJTabbedPane.addTab("auto-send", autoSendJPanel);

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addComponent(mainMenuJTabbedPane)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addComponent(mainMenuJTabbedPane)
    );

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void WSUrlActionPerformed(ActionEvent evt) {//GEN-FIRST:event_WSUrlActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_WSUrlActionPerformed

    private void WSHeadersKeyActionPerformed(ActionEvent evt) {//GEN-FIRST:event_WSHeadersKeyActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_WSHeadersKeyActionPerformed

    private void WSHeadersValueActionPerformed(ActionEvent evt) {//GEN-FIRST:event_WSHeadersValueActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_WSHeadersValueActionPerformed

    private void addSendEventNameTextActionPerformed(ActionEvent evt) {//GEN-FIRST:event_addSendEventNameTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_addSendEventNameTextActionPerformed

    private void sendEvnetMessageAreaCaretPositionChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_sendEvnetMessageAreaCaretPositionChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_sendEvnetMessageAreaCaretPositionChanged

    private void sendEvnetMessageAreaInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_sendEvnetMessageAreaInputMethodTextChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_sendEvnetMessageAreaInputMethodTextChanged

    private void connectButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_connectButtonActionPerformed
        // TODO add your handling code here:
        if(ConnectStatusEnum.connect.equals(ConnectStatusEnum.valueOf(connectButton.getText()))) {
            connect();
        }else if(ConnectStatusEnum.disConnect.equals(ConnectStatusEnum.valueOf(connectButton.getText()))){
            disConnect();
        }
    }//GEN-LAST:event_connectButtonActionPerformed

    private void addSendEventButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_addSendEventButtonActionPerformed
        // TODO add your handling code here:
        String eventName = addSendEventNameText.getText();
        String eventMessage = sendEvnetMessageArea.getText();
        if(StringUtils.isNotEmpty(eventName)){
            manualListModel.addData(eventName, Optional.of(eventMessage).orElse(""));
            updateList();
            try {
                manualListModel.data2File();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_addSendEventButtonActionPerformed

    private void delSendEventButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_delSendEventButtonActionPerformed
        // TODO add your handling code here:
        String selectEventName = sendEventList.getSelectedValue();
        if(StringUtils.isNotEmpty(selectEventName)){
            manualListModel.removeData(selectEventName);
            updateList();
            try {
                manualListModel.data2File();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_delSendEventButtonActionPerformed

    private void sendEventButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_sendEventButtonActionPerformed
        // TODO add your handling code here:
        String message = sendEvnetMessageArea.getText();
        if(StringUtils.isNotEmpty(message)) {
            message = requestReplacesContent.replacesContent(message);
            if (webSocketClient.sendMessage(message)) {
                appendRequestManualTextArea(JsonUtil.toPrettyFormat(message));
            }else{
                System.out.println("Message sending error !!!!!!!");
            }
        }
    }//GEN-LAST:event_sendEventButtonActionPerformed

    private void sendEventListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_sendEventListValueChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_sendEventListValueChanged

    private void sendEventListMouseClicked(MouseEvent evt) {//GEN-FIRST:event_sendEventListMouseClicked
        // TODO add your handling code here:
        String value = manualListModel.getData(sendEventList.getSelectedValue());
        if(StringUtils.isNotEmpty(value)){
            sendEvnetMessageArea.setText(JsonUtil.toPrettyFormat(value));
            addSendEventNameText.setText(sendEventList.getSelectedValue());
        }
    }//GEN-LAST:event_sendEventListMouseClicked

    private void addAutoSendEventButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_addAutoSendEventButtonActionPerformed
        // TODO add your handling code here:
        String eventName = autoSendEventNameText.getText();
        String eventMessage = autoSendEvnetMessageArea.getText();
        String interval = autoIntervalText.getText();
        if(StringUtils.isNotEmpty(eventName)){
            autoListModel.addData(eventName, Optional.of(eventMessage).orElse(""));
            if(StringUtils.isNotEmpty(interval)){
                autoIntervalListModel.addData(eventName,interval);
                try {
                    autoIntervalListModel.data2File();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            updateAutoList();
            try {
                autoListModel.data2File();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_addAutoSendEventButtonActionPerformed

    private void autoSendEventNameTextActionPerformed(ActionEvent evt) {//GEN-FIRST:event_autoSendEventNameTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_autoSendEventNameTextActionPerformed

    private void autoIntervalTextActionPerformed(ActionEvent evt) {//GEN-FIRST:event_autoIntervalTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_autoIntervalTextActionPerformed

    private void autoSendEventListMouseClicked(MouseEvent evt) {//GEN-FIRST:event_autoSendEventListMouseClicked
        // TODO add your handling code here:
        String selectEventName = autoSendEventList.getSelectedValue();
        String value = autoListModel.getData(selectEventName);
        if(StringUtils.isNotEmpty(value)){
            autoSendEvnetMessageArea.setText(JsonUtil.toPrettyFormat(value));
            autoSendEventNameText.setText(selectEventName);
            if(autoIntervalListModel.getData(selectEventName)!=null) {
                autoIntervalText.setText(autoIntervalListModel.getData(selectEventName).toString());
            }else{
                autoIntervalText.setText("");
            }
        }
    }//GEN-LAST:event_autoSendEventListMouseClicked

    private void delAutoSendEventButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_delAutoSendEventButtonActionPerformed
        // TODO add your handling code here:
        String selectEventName = autoSendEventList.getSelectedValue();
        if(StringUtils.isNotEmpty(selectEventName)){
            autoListModel.removeData(selectEventName);
            autoIntervalListModel.removeData(selectEventName);
            updateAutoList();
            try {
                autoListModel.data2File();
                autoIntervalListModel.data2File();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_delAutoSendEventButtonActionPerformed

    private void autoIntervalButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_autoIntervalButtonActionPerformed
        // TODO add your handling code here:
        String autoIntervalTextText = autoIntervalText.getText();
        String autoSendEventNameTextText = autoSendEventNameText.getText();
        String autoSendEvnetMessageAreaText = autoSendEvnetMessageArea.getText();
        if(AutoSendStatusEnum.openAutoSend.equals(AutoSendStatusEnum.valueOf(autoIntervalButton.getText()))){
            if(StringUtils.isNotEmpty(autoIntervalTextText)||StringUtils.isNotEmpty(autoSendEventNameTextText)||StringUtils.isNotEmpty(autoSendEvnetMessageAreaText)) {
                autoListModel.setActive(autoSendEventNameTextText,true);
                autoSendMessageHandler.buildAutoSendMessage(autoSendEventNameTextText,autoSendEvnetMessageAreaText,Integer.parseInt(autoIntervalTextText));
                autoIntervalButton.setText(AutoSendStatusEnum.closeAutoSend.name());
            }
        }else{
            autoListModel.setActive(autoSendEventNameTextText,false);
            autoSendMessageHandler.killTask(autoSendEventNameTextText);
            autoIntervalButton.setText(AutoSendStatusEnum.openAutoSend.name());
        }
        updateAutoList();
    }//GEN-LAST:event_autoIntervalButtonActionPerformed

    private void mainMenuJTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_mainMenuJTabbedPaneStateChanged
        if(mainMenuJTabbedPane.getSelectedComponent().equals(connectJPanel)){
            WSUrl.setText(connectModel.getConnectionUrl());
            IntStream.range(0,3).forEach(value -> {
                switch (value){
                    case 0:
                        WSHeadersKey.setText(connectModel.getHeaders().keySet().stream().skip(value).findFirst().orElse(""));
                        WSHeadersValue.setText(connectModel.getHeaders().get(connectModel.getHeaders().keySet().stream().skip(value).findFirst().orElse("")));
                        break;
                    case 1:
                        WSHeadersKey1.setText(connectModel.getHeaders().keySet().stream().skip(value).findFirst().orElse(""));
                        WSHeadersValue1.setText(connectModel.getHeaders().get(connectModel.getHeaders().keySet().stream().skip(value).findFirst().orElse("")));
                    case 2:
                        WSHeadersKey2.setText(connectModel.getHeaders().keySet().stream().skip(value).findFirst().orElse(""));
                        WSHeadersValue2.setText(connectModel.getHeaders().get(connectModel.getHeaders().keySet().stream().skip(value).findFirst().orElse("")));
                }
            });

        }else if(mainMenuJTabbedPane.getSelectedComponent().equals(manualSendJPanel)){
            updateList();
        }else if(mainMenuJTabbedPane.getSelectedComponent().equals(autoSendJPanel)){
            updateAutoList();
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_mainMenuJTabbedPaneStateChanged

    private void manualTextAreaMouseClicked(MouseEvent e) {//GEN-FIRST:event_manualTextAreaMouseClicked
        // TODO add your handling code here:
        if(e.getButton()==MouseEvent.BUTTON3)
        {
            //弹出式菜单
            JPopupMenu popup=new JPopupMenu();
            popup.add( createMenuItem((JTextArea)e.getSource(), "clearAll","clear all"));
            popup.show(e.getComponent(), e.getX(), e.getY());
        }
    }//GEN-LAST:event_manualTextAreaMouseClicked

    private void autoTextAreaMouseClicked(MouseEvent e) {//GEN-FIRST:event_autoTextAreaMouseClicked
        // TODO add your handling code here:
        if(e.getButton()==MouseEvent.BUTTON3)
        {
            //弹出式菜单
            JPopupMenu popup=new JPopupMenu();
            popup.add( createMenuItem((JTextArea)e.getSource(), "clearAll","clear all"));
            popup.show(e.getComponent(), e.getX(), e.getY());
        }
    }//GEN-LAST:event_autoTextAreaMouseClicked

    private void WSHeadersKey1ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_WSHeadersKey1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_WSHeadersKey1ActionPerformed

    private void WSHeadersValue1ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_WSHeadersValue1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_WSHeadersValue1ActionPerformed

    private void WSHeadersKey2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_WSHeadersKey2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_WSHeadersKey2ActionPerformed

    private void WSHeadersValue2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_WSHeadersValue2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_WSHeadersValue2ActionPerformed

    private JMenuItem createMenuItem(JTextArea jTextArea,String action,String text)
    {
        JMenuItem item=new JMenuItem(text);
        item.setActionCommand(action);
        item.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if("clearAll".equals(e.getActionCommand())) {
                    jTextArea.setText("");
                }
            }
        });
        return item;
    }

    public void connect(){
        String url = WSUrl.getText();
        String headerKey = WSHeadersKey.getText();
        String headerValue = WSHeadersValue.getText();
        String headerKey1 = WSHeadersKey1.getText();
        String headerValue1 = WSHeadersValue1.getText();
        String headerKey2 = WSHeadersKey2.getText();
        String headerValue2 = WSHeadersValue2.getText();
        if (StringUtils.isNotEmpty(url)) {
            HttpHeaders entries = new DefaultHttpHeaders();
            //entries.add("Host","sydney.bing.com");
            entries.add("Origin","https://www.bing.com");
            entries.add("Accept-Encoding" , "gzip, deflate, br");
            entries.add("Accept-Language" , "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6");
            entries.add("Cache-Control" , "no-cache" );
            entries.add("Connection" ,"Upgrade");
            entries.add("Upgrade" ,"websocket");
            entries.add("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.188");
            entries.add("Sec-Websocket-Extensions" ,"permessage-deflate; client_max_window_bits");
            entries.add("Sec-Websocket-Key" ,"/NUdQxmY3p9HsE0bFZNTyA==");
            entries.add("Sec-Websocket-Version" ,"13");
            if (StringUtils.isNotEmpty(headerKey) && StringUtils.isNotEmpty(headerValue)) {
                entries.add(headerKey, headerValue);
            }
            if (StringUtils.isNotEmpty(headerKey1) && StringUtils.isNotEmpty(headerValue1)) {
                entries.add(headerKey1, headerValue1);
            }
            if (StringUtils.isNotEmpty(headerKey2) && StringUtils.isNotEmpty(headerValue2)) {
                entries.add(headerKey2, headerValue2);
            }
            try {
                if (webSocketClient.connect(url, entries)) {
                    connectButton.setText(ConnectStatusEnum.disConnect.name());
                    connectButton.updateUI();
                    connectModel.setConnectionUrl(url);
                    Map<String, String> map = new LinkedHashMap<>();
                    for (Map.Entry<String, String> entry : entries) {
                        map.put(entry.getKey(),entry.getValue());
                    }
                    connectModel.setHeaders(map);
                    connectModel.data2File();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public void disConnect(){
        if(webSocketClient.disConnect()){
            connectButton.setText(ConnectStatusEnum.connect.name());
            connectButton.updateUI();
        }
    }

    private void updateList(){
        sendEventList.setModel(new AbstractListModel(){
            @Override
            public int getSize() {
                if (manualListModel==null) {
                    return 0;
                }
                return manualListModel.getSize();
            }
            @Override
            public Object getElementAt(int index) {
                return manualListModel.getElementAt(index);
            }
        });
        sendEventList.updateUI();
    }
    private void updateAutoList(){
        autoSendEventList.setModel(new AbstractListModel(){
            @Override
            public int getSize() {
                if (autoListModel==null) {
                    return 0;
                }
                return autoListModel.getSize();
            }
            @Override
            public Object getElementAt(int index) {
                return autoListModel.getElementAt(index);
            }
        });
        autoSendEventList.updateUI();
    }

    public void appendRequestManualTextArea(String str){
        manualTextArea.append("\n\nclient-------------->>>>>>>>>-------------server\n");
        manualTextArea.append(str);
    }
    public void appendResponseManualTextArea(String str){
        manualTextArea.append("\n\nclient--------------<<<<<<<<<-------------server\n");
        manualTextArea.append(str);
    }

    public void appendRequestAutoTextArea(String str){
        autoTextArea.append("\n\nclient-------------->>>>>>>>>-------------server\n");
        autoTextArea.append(str);
    }
    public void appendResponseAutoTextArea(String str){
        autoTextArea.append("\n\nclient--------------<<<<<<<<<-------------server\n");
        autoTextArea.append(str);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SwingApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SwingApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SwingApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SwingApp.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SwingApp().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private JPanel WSHeaders;
    private JTextField WSHeadersKey;
    private JTextField WSHeadersKey1;
    private JTextField WSHeadersKey2;
    private JTextField WSHeadersValue;
    private JTextField WSHeadersValue1;
    private JTextField WSHeadersValue2;
    private JTextField WSUrl;
    private JButton addAutoSendEventButton;
    private JButton addSendEventButton;
    private JTextField addSendEventNameText;
    private JButton autoIntervalButton;
    private JTextField autoIntervalText;
    private JList<String> autoSendEventList;
    private JTextField autoSendEventNameText;
    private JTextArea autoSendEvnetMessageArea;
    private JPanel autoSendJPanel;
    private JTextArea autoTextArea;
    private JButton connectButton;
    private JPanel connectJPanel;
    private JButton delAutoSendEventButton;
    private JButton delSendEventButton;
    private JLabel jLabel1;
    private JLabel jLabel2;
    private JPanel jPanel10;
    private JPanel jPanel11;
    private JPanel jPanel12;
    private JPanel jPanel13;
    private JPanel jPanel14;
    private JPanel jPanel2;
    private JPanel jPanel4;
    private JPanel jPanel5;
    private JPanel jPanel6;
    private JPanel jPanel7;
    private JPanel jPanel8;
    private JPanel jPanel9;
    private JScrollPane jScrollPane1;
    private JScrollPane jScrollPane2;
    private JScrollPane jScrollPane4;
    private JScrollPane jScrollPane5;
    private JScrollPane jScrollPane6;
    private JScrollPane jScrollPane7;
    private JSplitPane jSplitPane1;
    private JSplitPane jSplitPane2;
    private JSplitPane jSplitPane3;
    private JSplitPane jSplitPane4;
    private JTabbedPane mainMenuJTabbedPane;
    private JPanel manualSendJPanel;
    private JTextArea manualTextArea;
    private JButton sendEventButton;
    private JList<String> sendEventList;
    private JTextArea sendEvnetMessageArea;
    // End of variables declaration//GEN-END:variables
}
